#include "DebugConsole.h"
#include <assert.h>
#include <stdarg.h>
#include "TestFactory.h"

#ifdef WIN32
#include <tchar.h>
#endif

namespace AllTing
{

namespace Test
{

DebugConsole::~DebugConsole()
{
}
/*

UInt32 DebugConsole::Log(const Char* pszFormat, ...)
{
	va_list args;
	va_start(args, pszFormat);

#ifdef WIN32
#if _MSC_VER > 1300
	UInt32 nLen = _vstprintf_s(szBuffer_, DEBUG_MAX_LOG_BUFFER, pszFormat, args) + sizeof(Char);
#else
	UInt32 nLen = _vstprintf(szBuffer_, pszFormat, args) + sizeof(Char);
#endif
#else
	UInt32 nLen = vswprintf(szBuffer_, DEBUG_MAX_LOG_BUFFER, pszFormat, args) + sizeof(Char);
#endif
	
	szBuffer_[nLen] = 0x00;
	
	UInt32 nRet = Debug::Log(szBuffer_);

	va_end(args);

	return nRet;
}

Bool DebugConsole::Report()
{
	TestConstIterator itStart = TestFactory::Instance()->BeginTest();
	TestConstIterator itEnd = TestFactory::Instance()->EndTest();

	UInt32 nTestCount = TestFactory::Instance()->Size();
	UInt32 nFailedTest = 0;
	UInt32 nFailedAssert = 0;

	for(; itStart!=itEnd; ++itStart)
	{
		AssertConstIterator itAssertStart = (*itStart)->BeginFailedAssert();
		AssertConstIterator itAssertEnd = (*itStart)->EndFailedAssert();

		if(itAssertStart != itAssertEnd)
			++nFailedTest;

		for(; itAssertStart!=itAssertEnd; ++itAssertStart)
		{
			if(False == itAssertStart->strFile.empty() && 0 < itAssertStart->nLine)
			{
#ifdef WIN32
				Log(L"%s(%u) : Failed %s test\n", 
						itAssertStart->strFile.c_str(), itAssertStart->nLine, (*itStart)->Name());
#else
				Log(L"%S(%u) : Failed %S test\n", 
						itAssertStart->strFile.c_str(), itAssertStart->nLine, (*itStart)->Name());
#endif
				++nFailedAssert;
			}
		}
	}

	Log(L"\r\n============================================================================\r\n");
	Log(L"Done - %u tests(%u asserts), %u succeeded(%u asserts), %u failed(%u asserts)", 
				nTestCount, nAssert_, nTestCount-nFailedTest, nAssert_-nFailedAssert, nFailedTest, nFailedAssert);
	Log(L"\r\n============================================================================\r\n");

	return True;
}
*/

};	// namespace Test

}	// namespace AllTing